<?php

require '../classes/Conf.php';
require '../classes/Connection.php';
require '../classes/ConnectionSecure.php';
require '../classes/Usuarios.php';

$post_names = array('username', 'pass');
$registrando = true;
foreach ($post_names as $key => $value) {
    if (!isset($_POST[$value])) {
        echo "Faltan datos por diligenciar!";
        break;
    }
}

$error = "";
$logueado = false;
if ($registrando) {
    $objUsuario = new Usuarios();
    $username = (trim($_POST['username']));
    $pass = addslashes(trim($_POST['pass']));
    

    if ($objUsuario->usuario_valido($username, $pass) == true) {
        session_start();
        $logueado = true;
        $_SESSION['Username'] = trim($_POST['username']);
        echo "OK";
    } else {
        echo "Invalid Username/password";
    }
}
